/*
 *  ECE552H1 F Assignment 3
 *  File Name: mbq7.c
 *  Author: Mustafa Abbas
 *  Description:
 *      A microbenchmark that executes a fixed number of
 *      sequential memory accesses with strides and some random
 *      access to test a prefetcher
 */

#define BENCHMARK_SIZE 1000000

int main () {
    int i = 0;
    int x[BENCHMARK_SIZE];
    int y[BENCHMARK_SIZE];

    /* The loop below will access the memory in a pattern, and build up the pretfetch
       table */
    for (i=0; i<BENCHMARK_SIZE; i++) {
        if (i%7 == 0) {
            y[i] = x[i];
        }
    }

    /* the second loop should be completely prefetched */
    for (i=0; i<BENCHMARK_SIZE; i++) {
        if (i%7 == 0) {
            y[i] = x[i];
        }
    }
    return 0;
}

/* 
   .file   1 "mbq7.c"

# GNU C 2.7.2.3 [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C

# Cc1 defaults:
# -mgas -mgpOPT

# Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
# -quiet -dumpbase -O2 -o

gcc2_compiled.:
__gnu_compiled_c:
.text
.align  2
.globl  main

.text

.loc    1 13
.ent    main
main:
.frame  $sp,8000024,$31     # vars= 8000000, regs= 1/0, args= 16, extra= 0
.mask   0x80000000,-8
.fmask  0x00000000,0
li  $8,0x007a1218       # 8000024
subu    $sp,$sp,$8
addu    $9,$8,$sp
sw  $31,-8($9)
jal __main
move    $5,$0
li  $9,-1840709632          # 0x92490000
ori $9,$9,0x2493
li  $8,0x003d0000       # 3997696
ori $8,$8,0x0900
li  $7,0x000f0000       # 983040
ori $7,$7,0x423f
addu    $6,$sp,16
$L5:
mult    $5,$9
.set    noreorder
mfhi    $3
mflo    $2
#nop
#nop
.set    reorder
srl $2,$3,0
move    $3,$0
addu    $2,$5,$2
sra $2,$2,2
sra $4,$5,31
subu    $2,$2,$4
sll $4,$2,3
subu  $4,$4,$2
bne   $5,$4,$L4
.set    noreorder
lw  $3,0($6)
.set    reorder
addu    $2,$6,$8
sw  $3,0($2)
$L4:
addu    $6,$6,4
addu    $5,$5,1
slt $2,$7,$5
beq $2,$0,$L5
move    $5,$0
li  $9,-1840709632          # 0x92490000
ori $9,$9,0x2493
li  $8,0x003d0000       # 3997696
ori $8,$8,0x0900
li  $7,0x000f0000       # 983040
ori $7,$7,0x423f
addu    $6,$sp,16
$L11:
mult    $5,$9
.set    noreorder
mfhi    $3
mflo    $2
#nop
#nop
.set    reorder
srl $2,$3,0
move    $3,$0
addu    $2,$5,$2
sra $2,$2,2
sra $4,$5,31
subu    $2,$2,$4
sll $4,$2,3
subu    $4,$4,$2
bne $5,$4,$L10
    .set    noreorder
lw  $3,0($6)
    .set    reorder
    addu    $2,$6,$8
sw  $3,0($2)
    $L10:
    addu    $6,$6,4
    addu    $5,$5,1
    slt $2,$7,$5
    beq $2,$0,$L11
    move    $2,$0
    li  $8,0x007a1218   # 8000024
    addu    $9,$8,$sp
lw  $31,-8($9)
    addu    $sp,$sp,$8
    j   $31
    .end    main
    */
